package com.vip.websocket.service;

import com.vip.websocket.util.SpringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * Redis发布Service
 *
 * @author wgb
 * @date 2020/4/12 19:33
 */
@Component
public class PublishService {
    private StringRedisTemplate redisTemplate = SpringUtils.getBean(StringRedisTemplate.class);

    /**
     * 发布方法
     *
     * @param channel 消息发布订阅，主题
     * @param message 消息信息
     */
    public void publish(String channel, Object message) {
        redisTemplate.convertAndSend(channel, message);
    }
}
